# -*- coding: utf-8 -*-
# @Time    : 2024/11/29 上午9:57
# @Author  : wjx
# @Email   : kanxinxin@163.com
# @File    : upload_page.py
# @Software: PyCharm
from appium.webdriver.common.appiumby import AppiumBy as By
from pages.base_page import BasePage


class UploadPage(BasePage):
    # 定位器
    upload_menu_locator = (By.ID, 'com.xiachufang:id/create_recipe_btn')  # 传菜谱
    upload_works_locator = (By.ID, 'com.xiachufang:id/create_dish_btn')  # 传作品
    remember_diet_locator = (By.ID, 'com.xiachufang:id/create_diet_btn')  # 记饮食
    # 传菜谱打卡
    passing_menu_to_punch_in_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().resourceId('
                                                                '"com.xiachufang:id/iv_sticker")')
    # 选择第一张图片
    select_first_pic_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().resourceId('
                                                        '"com.xiachufang:id/item_photo_picker_photo").instance(1)')
    # 下一步
    nextStep_locator = (By.ANDROID_UIAUTOMATOR,'new UiSelector().resourceId("com.xiachufang:id/tv_next_step")')
    # 关闭
    close_locator = (By.XPATH,'//android.widget.TextView[@resource-id="com.xiachufang:id/navigation_right_btn"]')


    def click_upload_menu(self):
        """
        点击传菜谱
        :return: None
        """
        self.find_element(self.upload_menu_locator).click()

    def click_upload_works(self):
        """
        点击传作品
        :return:None
        """
        self.find_element(self.upload_works_locator).click()

    def click_remember_diet(self):
        """
        点击记饮食
        :return: None
        """
        self.find_element(self.remember_diet_locator).click()

    def click_passing_menu_to_punch_in(self):
        """
        点击传菜谱打卡
        :return: None
        """
        self.find_element(self.passing_menu_to_punch_in_locator).click()

    def click_first_pic(self):
        """
        点击第一章图片
        :return: None
        """
        self.find_element(self.select_first_pic_locator).click()

    def click_nextstep(self):
        """
        点击下一步
        :return: None
        """
        self.find_element(self.nextStep_locator).click()

    def click_close(self):
        """
        发布成功后点击关闭
        :return: None
        """
        self.find_element(self.close_locator).click()

